package offer;

public class offer53_II {
    public static void main(String[] args) {
        final Solution solution = new Solution();
        int[] nums = {0,1};
        solution.missingNumber(nums);
    }

    static class Solution {
        public int missingNumber(int[] nums) {
//            if(nums.length == 1){
//                return 1;
//            }
            int left = 0, right = nums.length - 1;
            return binarySearch(nums, 0, right);
        }

        public int binarySearch(int[] nums, int left, int right){
            while(left <  right){
                int mid = (left + right) / 2;
                if(nums[mid] == mid){
                    left = mid + 1;
                } else {
                    right = mid - 1;
                }
            }
            return nums[right]-1;
        }
    }
}
